home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Dev / mpatrol / man / cat3 / mpatrol.3
Text File  |  2000-05-27  |  65KB  |  1,321 lines

  1.  
  2.  
  3.  
  4. MPATROL(3)               mpatrol library               MPATROL(3)
  5.  
  6.  
  7. NNAAMMEE
  8.        mpatrol - dynamic memory allocation and tracing library
  9.  
  10. SSYYNNOOPPSSIISS
  11.        #include <mpatrol.h>
  12.  
  13.        void *malloc(size_t size);
  14.        void *calloc(size_t nelem, size_t size);
  15.        void *memalign(size_t align, size_t size);
  16.        void *valloc(size_t size);
  17.        void *pvalloc(size_t size);
  18.        char *strdup(const char *str);
  19.        char *strndup(const char *str, size_t size);
  20.        char *strsave(const char *str);
  21.        char *strnsave(const char *str, size_t size);
  22.        void *realloc(void *ptr, size_t size);
  23.        void *recalloc(void *ptr, size_t nelem, size_t size);
  24.        void *expand(void *ptr, size_t size);
  25.        void free(void *ptr);
  26.        void cfree(void *ptr, size_t nelem, size_t size);
  27.  
  28.        void *operator new(size_t size);
  29.        void *operator new[](size_t size);
  30.        void operator delete(void *ptr);
  31.        void operator delete[](void *ptr);
  32.        void (*set_new_handler(void (*func)(void)))(void);
  33.  
  34.        void *memset(void *ptr, int byte, size_t size);
  35.        void bzero(void *ptr, size_t size);
  36.        void *memccpy(void *dest, const void *src, int byte,
  37.                      size_t size);
  38.        void *memcpy(void *dest, const void *src, size_t size);
  39.        void *memmove(void *dest, const void *src, size_t size);
  40.        void bcopy(const void *src, void *dest, size_t size);
  41.        int memcmp(const void *ptr1, const void *ptr2,
  42.                   size_t size);
  43.        int bcmp(const void *ptr1, const void *ptr2, size_t size);
  44.        void *memchr(const void *ptr, int byte, size_t size);
  45.        void *memmem(const void *ptr1, size_t size1,
  46.                     const void *ptr2, size_t size2);
  47.  
  48.        int __mp_info(const void *ptr, __mp_allocinfo *info);
  49.        int __mp_printinfo(const void *ptr);
  50.        void __mp_memorymap(int stats);
  51.        void __mp_summary(void);
  52.        void __mp_check(void);
  53.        void (*__mp_prologue(void (*func)(const void *, size_t)))
  54.             (const void *, size_t);
  55.        void (*__mp_epilogue(void (*func)(const void *)))
  56.             (const void *);
  57.        void (*__mp_nomemory(void (*func)(void)))(void);
  58.  
  59. DDEESSCCRRIIPPTTIIOONN
  60.        The  _m_p_a_t_r_o_l  _l_i_b_r_a_r_y  contains implementations of dynamic
  61.  
  62.  
  63.  
  64. Release 1.2                16 May 2000                          1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. MPATROL(3)               mpatrol library               MPATROL(3)
  71.  
  72.  
  73.        memory allocation functions for C  and  C++  suitable  for
  74.        tracing  and debugging, and is available on UNIX, AmigaOS,
  75.        Windows and Netware platforms.  The library is intended to
  76.        be  used  without  requiring  any changes to existing user
  77.        source code except the inclusion of the  _m_p_a_t_r_o_l_._h  header
  78.        file, although additional functions are supplied for extra
  79.        tracing and control.  Note that the current version of the
  80.        mpatrol  library  is contained in the MMPPAATTRROOLL__VVEERRSSIIOONN pre-
  81.        processor macro.
  82.  
  83.        All of the function definitions in _m_p_a_t_r_o_l_._h can  be  dis-
  84.        abled  by defining the NNDDEEBBUUGG preprocessor macro, which is
  85.        the same macro used to control the behaviour of the aasssseerrtt
  86.        function.  If NNDDEEBBUUGG is defined then no macro redefinition
  87.        of functions will  take  place  and  all  special  mpatrol
  88.        library  functions  will evaluate to empty statements.  It
  89.        is intended that the NNDDEEBBUUGG preprocessor macro be  defined
  90.        in release builds.
  91.  
  92.        All  diagnostics  are  sent to the file _m_p_a_t_r_o_l_._l_o_g in the
  93.        current directory by default but this can  be  changed  at
  94.        run-time.   Additional  configuration  options can also be
  95.        changed at run-time  by  setting  and  altering  the  MMPPAA--
  96.        TTRROOLL__OOPPTTIIOONNSS  environment variable.  See EENNVVIIRROONNMMEENNTT below
  97.        for more details.
  98.  
  99.        Details of memory allocations and free memory  are  stored
  100.        internally as a tree structure for speed and also to allow
  101.        the best fit allocation algorithm to be used.   This  also
  102.        enables  the  library  to  perform intelligent resizing of
  103.        memory allocations and can be used to quickly determine if
  104.        an address has been allocated on the heap.
  105.  
  106.        On  systems  that  support  memory protection, the library
  107.        attempts to detect any illegal memory accesses and display
  108.        as  much information as it can obtain about the address in
  109.        question and where the illegal memory access occurred.
  110.  
  111.        Stack traceback information for every memory allocation is
  112.        available on some supported platforms, which is useful for
  113.        determining exactly where a  memory  allocation  was  per-
  114.        formed or for adding meaning to tracing.  Symbol names are
  115.        read from the executable file and also possibly  from  any
  116.        required  shared  libraries, and if the UUSSEEDDEEBBUUGG option is
  117.        used and is available then the debugging  section  in  the
  118.        executable  file  will  be  read  to  determine additional
  119.        source-level information.
  120.  
  121.        Memory allocation profiling is supported, with  statistics
  122.        about  every  memory  allocation and deallocation that was
  123.        made during the execution of a program being written to  a
  124.        file  at  program  termination if the PPRROOFF option is used.
  125.        The information stored in this file can then  be  used  by
  126.        the  mmpprrooff  command  to display various tables summarising
  127.  
  128.  
  129.  
  130. Release 1.2                16 May 2000                          2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. MPATROL(3)               mpatrol library               MPATROL(3)
  137.  
  138.  
  139.        the memory allocation behaviour of the program  that  pro-
  140.        duced it.
  141.  
  142. FFUUNNCCTTIIOONNSS
  143.        The  following  14 functions are available as replacements
  144.        for existing C library functions.  To use these  you  must
  145.        include  _m_p_a_t_r_o_l_._h before all other header files, although
  146.        on UNIX and Windows platforms (and AmigaOS when using ggcccc)
  147.        they  will be used anyway, albeit with slightly less trac-
  148.        ing information:
  149.  
  150.        mmaalllloocc Allocates _s_i_z_e uninitialised bytes  from  the  heap
  151.               and  returns  a  pointer  to  the first byte of the
  152.               allocation.  The pointer returned will be  suitably
  153.               aligned  for casting to any type and can be used to
  154.               store data of up to _s_i_z_e bytes in length.  If  _s_i_z_e
  155.               is  _0  then the memory allocated will be implicitly
  156.               rounded up to _1 byte.  If there is not enough space
  157.               in  the heap then the null pointer will be returned
  158.               and eerrrrnnoo will be set  to  EENNOOMMEEMM.   The  allocated
  159.               memory must be deallocated with ffrreeee or reallocated
  160.               with rreeaalllloocc.
  161.  
  162.        ccaalllloocc Allocates _n_e_l_e_m elements of  _s_i_z_e  zero-initialised
  163.               bytes  from  the  heap and returns a pointer to the
  164.               first byte of the allocation.  The pointer returned
  165.               will  be  suitably  aligned for casting to any type
  166.               and can be used to store data of up to _n_e_l_e_m _* _s_i_z_e
  167.               bytes  in  length.   If  _n_e_l_e_m _* _s_i_z_e is _0 then the
  168.               amount  of  memory  allocated  will  be  implicitly
  169.               rounded up to _1 byte.  If there is not enough space
  170.               in the heap then the null pointer will be  returned
  171.               and  eerrrrnnoo  will  be  set to EENNOOMMEEMM.  The allocated
  172.               memory must be deallocated with ffrreeee or reallocated
  173.               with rreeaalllloocc.
  174.  
  175.        mmeemmaalliiggnn
  176.               Allocates  _s_i_z_e  uninitialised  bytes from the heap
  177.               and returns a pointer to  the  first  byte  of  the
  178.               allocation.   The  pointer returned will be aligned
  179.               to _a_l_i_g_n bytes and can be used to store data of  up
  180.               to _s_i_z_e bytes in length.  If _a_l_i_g_n is zero then the
  181.               default system alignment will be used.  If _a_l_i_g_n is
  182.               not  a  power  of two then it will be rounded up to
  183.               the nearest power of two.  If _a_l_i_g_n is greater than
  184.               the  system  page size then it will be truncated to
  185.               that value.  If _s_i_z_e is _0 then the memory allocated
  186.               will  be implicitly rounded up to _1 byte.  If there
  187.               is not enough space  in  the  heap  then  the  null
  188.               pointer  will  be returned and eerrrrnnoo will be set to
  189.               EENNOOMMEEMM.  The allocated memory must  be  deallocated
  190.               with ffrreeee or reallocated with rreeaalllloocc, although the
  191.               latter  will  not  guarantee  the  preservation  of
  192.               alignment.
  193.  
  194.  
  195.  
  196. Release 1.2                16 May 2000                          3
  197.  
  198.  
  199.  
  200.  
  201.  
  202. MPATROL(3)               mpatrol library               MPATROL(3)
  203.  
  204.  
  205.        vvaalllloocc Allocates  _s_i_z_e  uninitialised  bytes from the heap
  206.               and returns a pointer to  the  first  byte  of  the
  207.               allocation.   The  pointer returned will be aligned
  208.               to the system page size and can be  used  to  store
  209.               data  of  up to _s_i_z_e bytes in length.  If _s_i_z_e is _0
  210.               then  the  memory  allocated  will  be   implicitly
  211.               rounded up to _1 byte.  If there is not enough space
  212.               in the heap then the null pointer will be  returned
  213.               and  eerrrrnnoo  will  be  set to EENNOOMMEEMM.  The allocated
  214.               memory must be deallocated with ffrreeee or reallocated
  215.               with  rreeaalllloocc, although the latter will not guaran-
  216.               tee the preservation of alignment.
  217.  
  218.        ppvvaalllloocc
  219.               Allocates _s_i_z_e uninitialised bytes  from  the  heap
  220.               and  returns  a  pointer  to  the first byte of the
  221.               allocation.  The pointer returned will  be  aligned
  222.               to  the  system  page size and can be used to store
  223.               data of up to _s_i_z_e bytes in length.  If _s_i_z_e  is  _0
  224.               then   the  memory  allocated  will  be  implicitly
  225.               rounded up  to  _1  page,  otherwise  _s_i_z_e  will  be
  226.               implicitly  rounded  up to a multiple of the system
  227.               page size.  If there is not  enough  space  in  the
  228.               heap  then  the  null  pointer will be returned and
  229.               eerrrrnnoo will be set to EENNOOMMEEMM.  The allocated  memory
  230.               must  be  deallocated with ffrreeee or reallocated with
  231.               rreeaalllloocc, although the latter will not guarantee the
  232.               preservation of alignment.
  233.  
  234.        ssttrrdduupp Allocates  exactly  enough  memory from the heap to
  235.               duplicate _s_t_r (including the terminating nul  char-
  236.               acter)  and  returns a pointer to the first byte of
  237.               the allocation after copying _s_t_r to the newly-allo-
  238.               cated  memory.   The  pointer returned will have no
  239.               alignment constraints and  can  be  used  to  store
  240.               character  data up to the length of _s_t_r.  If _s_t_r is
  241.               NNUULLLL then the null pointer will  be  returned.   If
  242.               there is not enough space in the heap then the null
  243.               pointer will be returned and eerrrrnnoo will be  set  to
  244.               EENNOOMMEEMM.   The  allocated memory must be deallocated
  245.               with ffrreeee or reallocated with rreeaalllloocc.
  246.  
  247.        ssttrrnndduupp
  248.               Allocates exactly enough memory from  the  heap  to
  249.               duplicate  _s_t_r (including the terminating nul char-
  250.               acter) and returns a pointer to the first  byte  of
  251.               the allocation after copying _s_t_r to the newly-allo-
  252.               cated memory.  The pointer returned  will  have  no
  253.               alignment  constraints  and  can  be  used to store
  254.               character data up to the length of _s_t_r.  If _s_t_r  is
  255.               NNUULLLL  then  the  null pointer will be returned.  If
  256.               the length of _s_t_r is greater than  _s_i_z_e  then  only
  257.               _s_i_z_e  characters will be allocated and copied, with
  258.               one additional byte  for  the  nul  character.   If
  259.  
  260.  
  261.  
  262. Release 1.2                16 May 2000                          4
  263.  
  264.  
  265.  
  266.  
  267.  
  268. MPATROL(3)               mpatrol library               MPATROL(3)
  269.  
  270.  
  271.               there is not enough space in the heap then the null
  272.               pointer will be returned and eerrrrnnoo will be  set  to
  273.               EENNOOMMEEMM.   The  allocated memory must be deallocated
  274.               with ffrreeee or reallocated with rreeaalllloocc.  This  func-
  275.               tion  is available for backwards compatibility with
  276.               older C libraries and should not  be  used  in  new
  277.               code.
  278.  
  279.        ssttrrssaavvee
  280.               Allocates  exactly  enough  memory from the heap to
  281.               duplicate _s_t_r (including the terminating nul  char-
  282.               acter)  and  returns a pointer to the first byte of
  283.               the allocation after copying _s_t_r to the newly-allo-
  284.               cated  memory.   The  pointer returned will have no
  285.               alignment constraints and  can  be  used  to  store
  286.               character  data up to the length of _s_t_r.  If _s_t_r is
  287.               NNUULLLL then the null pointer will  be  returned.   If
  288.               there is not enough space in the heap then the null
  289.               pointer will be returned and eerrrrnnoo will be  set  to
  290.               EENNOOMMEEMM.   The  allocated memory must be deallocated
  291.               with ffrreeee or reallocated with rreeaalllloocc.  This  func-
  292.               tion  is available for backwards compatibility with
  293.               older C libraries and should not  be  used  in  new
  294.               code.
  295.  
  296.        ssttrrnnssaavvee
  297.               Allocates  exactly  enough  memory from the heap to
  298.               duplicate _s_t_r (including the terminating nul  char-
  299.               acter)  and  returns a pointer to the first byte of
  300.               the allocation after copying _s_t_r to the newly-allo-
  301.               cated  memory.   The  pointer returned will have no
  302.               alignment constraints and  can  be  used  to  store
  303.               character  data up to the length of _s_t_r.  If _s_t_r is
  304.               NNUULLLL then the null pointer will  be  returned.   If
  305.               the  length  of  _s_t_r is greater than _s_i_z_e then only
  306.               _s_i_z_e characters will be allocated and copied,  with
  307.               one  additional  byte  for  the  nul character.  If
  308.               there is not enough space in the heap then the null
  309.               pointer  will  be returned and eerrrrnnoo will be set to
  310.               EENNOOMMEEMM.  The allocated memory must  be  deallocated
  311.               with  ffrreeee or reallocated with rreeaalllloocc.  This func-
  312.               tion is available for backwards compatibility  with
  313.               older  C  libraries  and  should not be used in new
  314.               code.
  315.  
  316.        rreeaalllloocc
  317.               Resizes the memory allocation beginning at  _p_t_r  to
  318.               _s_i_z_e  bytes and returns a pointer to the first byte
  319.               of the new allocation  after  copying  _p_t_r  to  the
  320.               newly-allocated  memory, which will be truncated if
  321.               _s_i_z_e is smaller than the original allocation.   The
  322.               pointer returned will be suitably aligned for cast-
  323.               ing to any type and can be used to store data of up
  324.               to  _s_i_z_e  bytes in length.  If _p_t_r is NNUULLLL then the
  325.  
  326.  
  327.  
  328. Release 1.2                16 May 2000                          5
  329.  
  330.  
  331.  
  332.  
  333.  
  334. MPATROL(3)               mpatrol library               MPATROL(3)
  335.  
  336.  
  337.               call will be equivalent to mmaalllloocc.  If  _s_i_z_e  is  _0
  338.               then  the  existing memory allocation will be freed
  339.               and the null pointer will be returned.  If _s_i_z_e  is
  340.               greater than the original allocation then the extra
  341.               space will be filled with uninitialised bytes.   If
  342.               there is not enough space in the heap then the null
  343.               pointer will be returned and eerrrrnnoo will be  set  to
  344.               EENNOOMMEEMM.   The  allocated memory must be deallocated
  345.               with ffrreeee and can be reallocated again  with  rreeaall--
  346.               lloocc.
  347.  
  348.        rreeccaalllloocc
  349.               Resizes  the  memory allocation beginning at _p_t_r to
  350.               _n_e_l_e_m elements of _s_i_z_e bytes and returns a  pointer
  351.               to the first byte of the new allocation after copy-
  352.               ing _p_t_r to the newly-allocated memory,  which  will
  353.               be  truncated  if  _n_e_l_e_m * _s_i_z_e is smaller than the
  354.               original allocation.  The pointer returned will  be
  355.               suitably aligned for casting to any type and can be
  356.               used to store data of up to _n_e_l_e_m * _s_i_z_e  bytes  in
  357.               length.   If  _p_t_r  is  NNUULLLL  then  the call will be
  358.               equivalent to ccaalllloocc.  If _n_e_l_e_m * _s_i_z_e  is  _0  then
  359.               the  existing  memory  allocation will be freed and
  360.               the null pointer will be returned.  If _n_e_l_e_m * _s_i_z_e
  361.               is  greater  than  the original allocation then the
  362.               extra space will be  filled  with  zero-initialised
  363.               bytes.   If  there  is not enough space in the heap
  364.               then the null pointer will be  returned  and  eerrrrnnoo
  365.               will  be  set to EENNOOMMEEMM.  The allocated memory must
  366.               be deallocated with ffrreeee  and  can  be  reallocated
  367.               again with rreeaalllloocc.  This function is available for
  368.               backwards compatibility with older C libraries  and
  369.               ccaalllloocc and should not be used in new code.
  370.  
  371.        eexxppaanndd Attempts  to resize the memory allocation beginning
  372.               at _p_t_r to _s_i_z_e bytes  and  either  returns  _p_t_r  if
  373.               there was enough space to resize it, or NNUULLLL if the
  374.               block could not be resized for a particular reason.
  375.               If  _p_t_r is NNUULLLL then the call will be equivalent to
  376.               mmaalllloocc.  If _s_i_z_e is  00  then  the  existing  memory
  377.               allocation  will be freed and the NNUULLLL pointer will
  378.               be returned.  If _s_i_z_e is greater than the  original
  379.               allocation then the extra space will be filled with
  380.               uninitialised bytes and if _s_i_z_e is  less  than  the
  381.               original  allocation  then the memory block will be
  382.               truncated.  If there is not  enough  space  in  the
  383.               heap  then  the  NNUULLLL  pointer will be returned and
  384.               eerrrrnnoo will be set to EENNOOMMEEMM.  The allocated  memory
  385.               must  be  deallocated  with ffrreeee and can be reallo-
  386.               cated again with rreeaalllloocc.  This function is  avail-
  387.               able  for  backwards  compatibility  with  older  C
  388.               libraries and should not be used in new code.
  389.  
  390.        ffrreeee   Frees the memory allocation beginning at _p_t_r so the
  391.  
  392.  
  393.  
  394. Release 1.2                16 May 2000                          6
  395.  
  396.  
  397.  
  398.  
  399.  
  400. MPATROL(3)               mpatrol library               MPATROL(3)
  401.  
  402.  
  403.               memory  can  be  reused by another call to allocate
  404.               memory.  If _p_t_r is NNUULLLL  then  no  memory  will  be
  405.               freed.   All  of  the  previous  contents  will  be
  406.               destroyed.
  407.  
  408.        ccffrreeee  Frees the memory allocation beginning at _p_t_r so the
  409.               memory  can  be  reused by another call to allocate
  410.               memory.  If _p_t_r is NNUULLLL  then  no  memory  will  be
  411.               freed.   All  of  the  previous  contents  will  be
  412.               destroyed.   The  _n_e_l_e_m  and  _s_i_z_e  parameters  are
  413.               ignored  in  this implementation.  This function is
  414.               available for backwards compatibility with older  C
  415.               libraries  and ccaalllloocc and should not be used in new
  416.               code.
  417.  
  418.        The following 5 functions are  available  as  replacements
  419.        for  existing  C++ library functions, but the replacements
  420.        in _m_p_a_t_r_o_l_._h will only be used if the MMPP__NNOOCCPPLLUUSSPPLLUUSS  pre-
  421.        processor  macro  is  not  defined.  To use these you must
  422.        include _m_p_a_t_r_o_l_._h before all other header files,  although
  423.        on UNIX and Windows platforms (and AmigaOS when using ggcccc)
  424.        they will be used anyway, albeit with slightly less  trac-
  425.        ing information:
  426.  
  427.        ooppeerraattoorr nneeww
  428.               Allocates  _s_i_z_e  uninitialised  bytes from the heap
  429.               and returns a pointer to  the  first  byte  of  the
  430.               allocation.   The pointer returned will be suitably
  431.               aligned for casting to any type and can be used  to
  432.               store  data of up to _s_i_z_e bytes in length.  If _s_i_z_e
  433.               is _0 then the memory allocated will  be  implicitly
  434.               rounded up to _1 byte.  If there is not enough space
  435.               in the heap then the null pointer will be  returned
  436.               and  eerrrrnnoo  will  be  set to EENNOOMMEEMM - no exceptions
  437.               will be thrown.  The allocated memory must be deal-
  438.               located with ooppeerraattoorr ddeelleettee.
  439.  
  440.        ooppeerraattoorr nneeww[[]]
  441.               Allocates  _s_i_z_e  uninitialised  bytes from the heap
  442.               and returns a pointer to  the  first  byte  of  the
  443.               allocation.   The pointer returned will be suitably
  444.               aligned for casting to any type and can be used  to
  445.               store  data of up to _s_i_z_e bytes in length.  If _s_i_z_e
  446.               is _0 then the memory allocated will  be  implicitly
  447.               rounded up to _1 byte.  If there is not enough space
  448.               in the heap then the null pointer will be  returned
  449.               and  eerrrrnnoo  will  be  set to EENNOOMMEEMM - no exceptions
  450.               will be thrown.  The allocated memory must be deal-
  451.               located with ooppeerraattoorr ddeelleettee[[]].
  452.  
  453.        ooppeerraattoorr ddeelleettee
  454.               Frees the memory allocation beginning at _p_t_r so the
  455.               memory can be reused by another  call  to  allocate
  456.               memory.   If  _p_t_r  is  NNUULLLL  then no memory will be
  457.  
  458.  
  459.  
  460. Release 1.2                16 May 2000                          7
  461.  
  462.  
  463.  
  464.  
  465.  
  466. MPATROL(3)               mpatrol library               MPATROL(3)
  467.  
  468.  
  469.               freed.   All  of  the  previous  contents  will  be
  470.               destroyed.   This  function  must only be used with
  471.               memory allocated by ooppeerraattoorr nneeww.
  472.  
  473.        ooppeerraattoorr ddeelleettee[[]]
  474.               Frees the memory allocation beginning at _p_t_r so the
  475.               memory  can  be  reused by another call to allocate
  476.               memory.  If _p_t_r is NNUULLLL  then  no  memory  will  be
  477.               freed.   All  of  the  previous  contents  will  be
  478.               destroyed.  This function must only  be  used  with
  479.               memory allocated by ooppeerraattoorr nneeww[[]].
  480.  
  481.        sseett__nneeww__hhaannddlleerr
  482.               Installs  a low-memory handler specifically for use
  483.               with ooppeerraattoorr nneeww and ooppeerraattoorr nneeww[[]] and returns  a
  484.               pointer to the previously installed handler, or the
  485.               null pointer if  no  handler  had  been  previously
  486.               installed.   This will be called repeatedly by both
  487.               functions when they would normally return NNUULLLL, and
  488.               this  loop will continue until they manage to allo-
  489.               cate the requested space.  The  default  low-memory
  490.               handler  for  the  C++ operators will terminate the
  491.               program and write an out of memory message  to  the
  492.               log file.  Note that this function is equivalent to
  493.               ____mmpp__nnoommeemmoorryy  and   will   replace   the   handler
  494.               installed by that function.
  495.  
  496.        The  following  10 functions are available as replacements
  497.        for existing C library memory operation functions.  To use
  498.        these  you  must include _m_p_a_t_r_o_l_._h before all other header
  499.        files, although on UNIX and Windows platforms (and AmigaOS
  500.        when  using  ggcccc)  they  will  be used anyway, albeit with
  501.        slightly less tracing information:
  502.  
  503.        mmeemmsseett Writes _s_i_z_e bytes of value _b_y_t_e to the memory loca-
  504.               tion  beginning at _p_t_r and returns _p_t_r.  If _s_i_z_e is
  505.               00 then no bytes will be written.  If the  operation
  506.               would  affect  an existing memory allocation in the
  507.               heap but would straddle  that  allocation's  bound-
  508.               aries  then  an  error message will be generated in
  509.               the log file and no bytes will be written.
  510.  
  511.        bbzzeerroo  Writes _s_i_z_e  zero  bytes  to  the  memory  location
  512.               beginning  at _p_t_r.  If _s_i_z_e is 00 then no bytes will
  513.               be written.   If  the  operation  would  affect  an
  514.               existing  memory  allocation  in the heap but would
  515.               straddle that allocation's boundaries then an error
  516.               message  will  be  generated in the log file and no
  517.               bytes will be written.  This function is  available
  518.               for  backwards compatibility with older C libraries
  519.               and should not be used in new code.
  520.  
  521.        mmeemmccccppyy
  522.               Copies _s_i_z_e bytes from  _s_r_c  to  _d_e_s_t  and  returns
  523.  
  524.  
  525.  
  526. Release 1.2                16 May 2000                          8
  527.  
  528.  
  529.  
  530.  
  531.  
  532. MPATROL(3)               mpatrol library               MPATROL(3)
  533.  
  534.  
  535.               NNUULLLL,  or  copies  the  number  of  bytes up to and
  536.               including the first  occurrence  of  _b_y_t_e  if  _b_y_t_e
  537.               exists  within  the  specified  range and returns a
  538.               pointer to the first byte after _b_y_t_e.  If _s_i_z_e is 00
  539.               or  _s_r_c  is  the same as _d_e_s_t then no bytes will be
  540.               copied.  The source and destination  ranges  should
  541.               not overlap, otherwise a warning will be written to
  542.               the log file.  If the  operation  would  affect  an
  543.               existing  memory  allocation  in the heap but would
  544.               straddle that allocation's boundaries then an error
  545.               message  will  be  generated in the log file and no
  546.               bytes will be copied.
  547.  
  548.        mmeemmccppyy Copies _s_i_z_e bytes from  _s_r_c  to  _d_e_s_t  and  returns
  549.               _d_e_s_t.  If _s_i_z_e is 00 or _s_r_c is the same as _d_e_s_t then
  550.               no bytes will be copied.  The source  and  destina-
  551.               tion ranges should not overlap, otherwise a warning
  552.               will be written to the log file.  If the  operation
  553.               would  affect  an existing memory allocation in the
  554.               heap but would straddle  that  allocation's  bound-
  555.               aries  then  an  error message will be generated in
  556.               the log file and no bytes will be copied.
  557.  
  558.        mmeemmmmoovvee
  559.               Copies _s_i_z_e bytes from  _s_r_c  to  _d_e_s_t  and  returns
  560.               _d_e_s_t.  If _s_i_z_e is 00 or _s_r_c is the same as _d_e_s_t then
  561.               no bytes will be copied.  If  the  operation  would
  562.               affect  an  existing  memory allocation in the heap
  563.               but would  straddle  that  allocation's  boundaries
  564.               then  an error message will be generated in the log
  565.               file and no bytes will be copied.
  566.  
  567.        bbccooppyy  Copies _s_i_z_e bytes from _s_r_c to _d_e_s_t.  If _s_i_z_e  is  00
  568.               or  _s_r_c  is  the same as _d_e_s_t then no bytes will be
  569.               copied.  If the operation would affect an  existing
  570.               memory  allocation  in  the heap but would straddle
  571.               that allocation's boundaries then an error  message
  572.               will be generated in the log file and no bytes will
  573.               be copied.  This function is  available  for  back-
  574.               wards  compatibility  with  older  C  libraries and
  575.               should not be used in new code.
  576.  
  577.        mmeemmccmmpp Compares _s_i_z_e bytes from _p_t_r_1 and _p_t_r_2 and  returns
  578.               00 if all of the bytes are identical, or returns the
  579.               byte difference of the first differing  bytes.   If
  580.               _s_i_z_e is 00 or _p_t_r_1 is the same as _p_t_r_2 then no bytes
  581.               will be compared.  If the operation would read from
  582.               an existing memory allocation in the heap but would
  583.               straddle that allocation's boundaries then an error
  584.               message  will  be  generated in the log file and no
  585.               bytes will be compared.
  586.  
  587.        bbccmmpp   Compares _s_i_z_e bytes from _p_t_r_1 and _p_t_r_2 and  returns
  588.               00 if all of the bytes are identical, or returns the
  589.  
  590.  
  591.  
  592. Release 1.2                16 May 2000                          9
  593.  
  594.  
  595.  
  596.  
  597.  
  598. MPATROL(3)               mpatrol library               MPATROL(3)
  599.  
  600.  
  601.               byte difference of the first differing  bytes.   If
  602.               _s_i_z_e is 00 or _p_t_r_1 is the same as _p_t_r_2 then no bytes
  603.               will be compared.  If the operation would read from
  604.               an existing memory allocation in the heap but would
  605.               straddle that allocation's boundaries then an error
  606.               message  will  be  generated in the log file and no
  607.               bytes will be compared.  This function is available
  608.               for  backwards compatibility with older C libraries
  609.               and should not be used in new code.
  610.  
  611.        mmeemmcchhrr Searches up to _s_i_z_e bytes  in  _p_t_r  for  the  first
  612.               occurrence  of  _b_y_t_e and returns a pointer to it or
  613.               NNUULLLL if no such byte occurs.  If _s_i_z_e is 00 then  no
  614.               bytes  will  be  searched.   If the operation would
  615.               affect an existing memory allocation  in  the  heap
  616.               but  would  straddle  that  allocation's boundaries
  617.               then an error message will be generated in the  log
  618.               file and no bytes will be searched.
  619.  
  620.        mmeemmmmeemm Searches  up  to  _s_i_z_e_1 bytes in _p_t_r_1 for the first
  621.               occurrence of _p_t_r_2 (which is exactly _s_i_z_e_2 bytes in
  622.               length)  and  returns a pointer to it or NNUULLLL if no
  623.               such sequence of bytes occur.  If _s_i_z_e_1 or _s_i_z_e_2 is
  624.               00 then no bytes will be searched.  If the operation
  625.               would affect an existing memory allocation  in  the
  626.               heap  but  would  straddle that allocation's bound-
  627.               aries then an error message will  be  generated  in
  628.               the log file and no bytes will be searched.
  629.  
  630.        The  following  8  functions are available as support rou-
  631.        tines for additional control and tracing  in  the  mpatrol
  632.        library.   To  use  these you should include the _m_p_a_t_r_o_l_._h
  633.        header file:
  634.  
  635.        ____mmpp__iinnffoo
  636.               Obtains information about a specific memory alloca-
  637.               tion  by  placing statistics about _p_t_r in _i_n_f_o.  If
  638.               _p_t_r does not belong to a previously allocated  mem-
  639.               ory allocation then _0 will be returned, otherwise _1
  640.               will be returned and _i_n_f_o will contain the  follow-
  641.               ing information:
  642.  
  643.               FFiieelldd   DDeessccrriippttiioonn
  644.  
  645.               bblloocckk   Pointer to first byte of alloc.
  646.               ssiizzee    Size of alloc in bytes.
  647.               ttyyppee    Type of function which allocated memory.
  648.               aalllloocc   Allocation index.
  649.               rreeaalllloocc Number of times reallocated.
  650.               tthhrreeaadd  Thread identifier.
  651.               ffuunncc    Function in which alloc took place.
  652.               ffiillee    File in which alloc took place.
  653.               lliinnee    Line number at which alloc took place.
  654.               ssttaacckk   Pointer to function call stack.
  655.  
  656.  
  657.  
  658. Release 1.2                16 May 2000                         10
  659.  
  660.  
  661.  
  662.  
  663.  
  664. MPATROL(3)               mpatrol library               MPATROL(3)
  665.  
  666.  
  667.               ffrreeeedd   Indicates if alloc has been freed.
  668.  
  669.        ____mmpp__pprriinnttiinnffoo
  670.               Displays  information about a specific memory allo-
  671.               cation containing _p_t_r to the  standard  error  file
  672.               stream.   If  _p_t_r  does  not belong to a previously
  673.               allocated  memory  allocation  then   _0   will   be
  674.               returned, otherwise _1 will be returned.  This func-
  675.               tion is intended to be called from within a  debug-
  676.               ger.
  677.  
  678.        ____mmpp__mmeemmoorryymmaapp
  679.               If _s_t_a_t_s is non-zero then the current statistics of
  680.               the mpatrol library will be displayed.  If the heap
  681.               contains  at  least  one  allocated,  freed or free
  682.               block then a map of the current heap will  also  be
  683.               displayed.
  684.  
  685.        ____mmpp__ssuummmmaarryy
  686.               Displays information about the current state of the
  687.               mpatrol library, including  its  settings  and  any
  688.               relevant statistics.
  689.  
  690.        ____mmpp__cchheecckk
  691.               Forces the library to perform an immediate check of
  692.               the overflow buffers of every memory allocation and
  693.               to  ensure  that  nothing  has overwritten any free
  694.               blocks.
  695.  
  696.        ____mmpp__pprroolloogguuee
  697.               Installs a prologue function to  be  called  before
  698.               any memory allocation, reallocation or deallocation
  699.               function.  This function will return a  pointer  to
  700.               the  previously installed prologue function, or the
  701.               null pointer if no prologue function had been  pre-
  702.               viously installed.  The following arguments will be
  703.               used to call the prologue function:
  704.  
  705.               AArrgguummeenntt 11 AArrgguummeenntt 22 CCaalllleedd bbyy
  706.  
  707.               _-_1         _s_i_z_e       mmaalllloocc, etc.
  708.               _p_t_r        _s_i_z_e       rreeaalllloocc, etc.
  709.               _p_t_r        _-_1         ffrreeee, etc.
  710.               _p_t_r        _-_2         ssttrrdduupp, etc.
  711.  
  712.        ____mmpp__eeppiilloogguuee
  713.               Installs an epilogue function to  be  called  after
  714.               any memory allocation, reallocation or deallocation
  715.               function.  This function will return a  pointer  to
  716.               the  previously installed epilogue function, or the
  717.               null pointer if no epilogue function had been  pre-
  718.               viously installed.  The following arguments will be
  719.               used to call the epilogue function:
  720.  
  721.  
  722.  
  723.  
  724. Release 1.2                16 May 2000                         11
  725.  
  726.  
  727.  
  728.  
  729.  
  730. MPATROL(3)               mpatrol library               MPATROL(3)
  731.  
  732.  
  733.               AArrgguummeenntt CCaalllleedd bbyy
  734.  
  735.               _p_t_r      mmaalllloocc, rreeaalllloocc, ssttrrdduupp, etc.
  736.               _-_1       ffrreeee, etc.
  737.  
  738.        ____mmpp__nnoommeemmoorryy
  739.               Installs a low-memory handler and returns a pointer
  740.               to  the  previously  installed handler, or the null
  741.               pointer  if  no   handler   had   been   previously
  742.               installed.   This  will  be called once by C memory
  743.               allocation functions, and repeatedly by C++  memory
  744.               allocation  functions,  when  they  would  normally
  745.               return NNUULLLL.  Note that this function is equivalent
  746.               to  sseett__nneeww__hhaannddlleerr  and  will  replace the handler
  747.               installed by that function.
  748.  
  749. LLIINNKKIINNGG
  750.        In order to use the mpatrol library on UNIX platforms, the
  751.        following  libraries  must  be  linked in before any other
  752.        library that defines dynamic memory  allocation  functions
  753.        with the same names:
  754.  
  755.         LLiibbrraarryy        RReeaassoonn
  756.  
  757.         _-_l_m_p_a_t_r_o_l      To use this library.
  758.         _-_l_e_l_f          If built with FFOORRMMAATT==FFOORRMMAATT__EELLFF3322.
  759.         _-_l_b_f_d _-_l_i_b_e_r_t_y If built with FFOORRMMAATT==FFOORRMMAATT__BBFFDD.
  760.         _-_l_p_t_h_r_e_a_d      If built with MMPP__TTHHRREEAADDSS__SSUUPPPPOORRTT.
  761.  
  762.        On  UNIX platforms, if there were no calls to memory allo-
  763.        cation functions before _-_l_m_p_a_t_r_o_l appears on the link line
  764.        then  the mpatrol library will not be linked in.  However,
  765.        this can be overridden by  placing  _-_u_m_a_l_l_o_c  just  before
  766.        that point.
  767.  
  768.        You  may  also wish to set your core file size limit to be
  769.        zero before running any programs linked with  the  mpatrol
  770.        library as the extra memory that the library uses can make
  771.        such files much larger than normal, and if you  are  plan-
  772.        ning  on using a symbolic debugger then you won't need the
  773.        core files anyway.
  774.  
  775. EENNVVIIRROONNMMEENNTT
  776.        The library can read certain options at run-time  from  an
  777.        environment  variable  called MMPPAATTRROOLL__OOPPTTIIOONNSS.  This vari-
  778.        able must contain one or more valid option  keywords  from
  779.        the  list below and must be no longer than 1024 characters
  780.        in length.  If MMPPAATTRROOLL__OOPPTTIIOONNSS is unset or empty then  the
  781.        default settings will be used.
  782.  
  783.        The   syntax   for   options  specified  within  the  MMPPAA--
  784.        TTRROOLL__OOPPTTIIOONNSS   environment   variable   is    OOPPTTIIOONN    or
  785.        OOPPTTIIOONN=_V_A_L_U_E,  where  OOPPTTIIOONN  is  a  keyword from the list
  786.        below and _V_A_L_U_E is the setting for that option.  If  _V_A_L_U_E
  787.  
  788.  
  789.  
  790. Release 1.2                16 May 2000                         12
  791.  
  792.  
  793.  
  794.  
  795.  
  796. MPATROL(3)               mpatrol library               MPATROL(3)
  797.  
  798.  
  799.        is  numeric  then it may be specified using binary, octal,
  800.        decimal or  hexadecimal  notation,  with  binary  notation
  801.        beginning  with  either _0_b or _0_B.  If _V_A_L_U_E is a character
  802.        string containing spaces then it may be quoted using  dou-
  803.        ble  quotes.  No whitespace may appear between the _= sign,
  804.        but whitespace  must  appear  between  different  options.
  805.        Note  that  option  keywords  can be given in lowercase as
  806.        well as uppercase, or a mixture of both.
  807.  
  808.        AALLLLOOCCBBYYTTEE=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  809.               Specifies an 8-bit byte pattern with which to  pre-
  810.               fill  newly-allocated  memory.  This can be used to
  811.               detect the use of memory which has  not  been  ini-
  812.               tialised  after allocation.  Note that this setting
  813.               will not affect memory  allocated  with  ccaalllloocc  or
  814.               rreeccaalllloocc  as  these  functions always prefill allo-
  815.               cated memory with an 8-bit byte  pattern  of  zero.
  816.               Default value: AALLLLOOCCBBYYTTEE=_0_x_F_F.
  817.  
  818.        AALLLLOOCCSSTTOOPP=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  819.               Specifies  an allocation index at which to stop the
  820.               program when it is being allocated.  When the  num-
  821.               ber  of  memory allocations reaches this number the
  822.               program will be halted, and its state may be  exam-
  823.               ined  at  that  point by using a suitable debugger.
  824.               Note that this setting will be ignored if its value
  825.               is zero.  Default value: AALLLLOOCCSSTTOOPP=_0.
  826.  
  827.        AALLLLOOWWOOFFLLOOWW
  828.               Specifies  that  a  warning  rather  than  an error
  829.               should be produced if any memory operation function
  830.               overflows  the  boundaries  of a memory allocation,
  831.               and that the operation should still  be  performed.
  832.               This  option is provided for circumstances where it
  833.               is desirable for the memory operation  to  be  per-
  834.               formed,  regardless  of  whether it is erroneous or
  835.               not.
  836.  
  837.        AAUUTTOOSSAAVVEE=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  838.               Specifies the frequency at  which  to  periodically
  839.               write  the  profiling  data to the profiling output
  840.               file.  When the total  number  of  profiled  memory
  841.               allocations and deallocations is a multiple of this
  842.               number then the current profiling information  will
  843.               be  written  to  the  profiling  output file.  This
  844.               option can be used to instruct the mpatrol  library
  845.               to dump out any profiling information just before a
  846.               fatal error occurs in a program, for example.  Note
  847.               that  this  setting will be ignored if its value is
  848.               zero.  Default value: AAUUTTOOSSAAVVEE=_0.
  849.  
  850.        CCHHEECCKK=_u_n_s_i_g_n_e_d _r_a_n_g_e
  851.               Specifies a range of allocation indices at which to
  852.               check  the  integrity  of  free memory and overflow
  853.  
  854.  
  855.  
  856. Release 1.2                16 May 2000                         13
  857.  
  858.  
  859.  
  860.  
  861.  
  862. MPATROL(3)               mpatrol library               MPATROL(3)
  863.  
  864.  
  865.               buffers.  The range must be specified  as  no  more
  866.               than two unsigned integers separated by a dash.  If
  867.               numbers on either the left side or the  right  side
  868.               of  the  dash are omitted then they will be assumed
  869.               to be _0 and _i_n_f_i_n_i_t_y respectively.  A value of _0 on
  870.               its  own  indicates that no such checking will ever
  871.               be performed.  This option can be used to speed  up
  872.               the  execution  speed of the library at the expense
  873.               of checking.  Default value: CCHHEECCKK=_-.
  874.  
  875.        CCHHEECCKKAALLLL
  876.               Equivalent to the  CCHHEECCKKAALLLLOOCCSS,  CCHHEECCKKRREEAALLLLOOCCSS  and
  877.               CCHHEECCKKFFRREEEESS options specified together.
  878.  
  879.        CCHHEECCKKAALLLLOOCCSS
  880.               Checks  that no attempt is made to allocate a block
  881.               of memory of size zero.  A warning will  be  issued
  882.               for every such case.
  883.  
  884.        CCHHEECCKKFFRREEEESS
  885.               Checks that no attempt is made to deallocate a NNUULLLL
  886.               pointer.  A warning will be issued for  every  such
  887.               case.
  888.  
  889.        CCHHEECCKKRREEAALLLLOOCCSS
  890.               Checks that no attempt is made to reallocate a NNUULLLL
  891.               pointer or resize an existing block  of  memory  to
  892.               size  zero.  Warnings will be issued for every such
  893.               case.
  894.  
  895.        DDEEFFAALLIIGGNN=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  896.               Specifies the default alignment for general-purpose
  897.               memory  allocations,  which  must be a power of two
  898.               (and will be rounded up to the nearest power of two
  899.               if it is not).  The default alignment for a partic-
  900.               ular system is calculated at run-time.
  901.  
  902.        FFAAIILLFFRREEQQ=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  903.               Specifies the frequency at which all memory alloca-
  904.               tions  will randomly fail.  For example, a value of
  905.               _1_0 will mean that roughly 1 in  10  memory  alloca-
  906.               tions  will fail, but a value of _0 will disable all
  907.               random failures.  This option  can  be  useful  for
  908.               stress-testing   an  application.   Default  value:
  909.               FFAAIILLFFRREEQQ=_0.
  910.  
  911.        FFAAIILLSSEEEEDD=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  912.               Specifies the random number seed which will be used
  913.               when determining which memory allocations will ran-
  914.               domly fail.  A value of _0 will instruct the library
  915.               to  pick  a  random seed every time it is run.  Any
  916.               other value will mean that the random failures will
  917.               be the same every time the program is run, but only
  918.               as long as the seed stays the same.  Default value:
  919.  
  920.  
  921.  
  922. Release 1.2                16 May 2000                         14
  923.  
  924.  
  925.  
  926.  
  927.  
  928. MPATROL(3)               mpatrol library               MPATROL(3)
  929.  
  930.  
  931.               FFAAIILLSSEEEEDD=_0.
  932.  
  933.        FFRREEEEBBYYTTEE=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  934.               Specifies  an 8-bit byte pattern with which to pre-
  935.               fill newly-freed  memory.   This  can  be  used  to
  936.               detect the use of memory which has just been freed.
  937.               It is also used internally  to  ensure  that  freed
  938.               memory  has  not  been  overwritten.  Note that the
  939.               freed memory may be reused the next time a block of
  940.               memory  is  allocated  and  so once memory has been
  941.               freed its contents are not guaranteed to remain the
  942.               same as the specified byte pattern.  Default value:
  943.               FFRREEEEBBYYTTEE=_0_x_5_5.
  944.  
  945.        FFRREEEESSTTOOPP=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  946.               Specifies an allocation index at which to stop  the
  947.               program  when  it  is being freed.  When the memory
  948.               allocation with the specified allocation  index  is
  949.               to  be  freed  the  program will be halted, and its
  950.               state may be examined at that point using  a  suit-
  951.               able  debugger.   Note  that  this  setting will be
  952.               ignored if  its  value  is  zero.   Default  value:
  953.               FFRREEEESSTTOOPP=_0.
  954.  
  955.        HHEELLPP   Displays  a  quick-reference  option summary to the
  956.               ssttddeerrrr file stream.
  957.  
  958.        LLAARRGGEEBBOOUUNNDD=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  959.               Specifies the limit in bytes  up  to  which  memory
  960.               allocations  should  be classified as large alloca-
  961.               tions for profiling purposes.  This limit  must  be
  962.               greater  than the small and medium bounds.  Default
  963.               value: LLAARRGGEEBBOOUUNNDD=_2_0_4_8.
  964.  
  965.        LLIIMMIITT=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  966.               Specifies the limit in bytes at  which  all  memory
  967.               allocations should fail if the total allocated mem-
  968.               ory should increase beyond this.  This can be  used
  969.               to  stress-test  software  to see how it behaves in
  970.               low memory conditions.  The internal memory used by
  971.               the  library  itself will not be counted as part of
  972.               the total heap size, but on some systems there  may
  973.               be  a small amount of memory required to initialise
  974.               the library itself.  Note that this setting will be
  975.               ignored  if  its  value  is  zero.   Default value:
  976.               LLIIMMIITT=_0.
  977.  
  978.        LLOOGGAALLLL Equivalent to the LLOOGGAALLLLOOCCSS, LLOOGGRREEAALLLLOOCCSS,  LLOOGGFFRREEEESS
  979.               and LLOOGGMMEEMMOORRYY options specified together.
  980.  
  981.        LLOOGGAALLLLOOCCSS
  982.               Specifies  that  all  memory  allocations are to be
  983.               logged and sent to the log  file.   Note  that  any
  984.               memory  allocations  made internally by the library
  985.  
  986.  
  987.  
  988. Release 1.2                16 May 2000                         15
  989.  
  990.  
  991.  
  992.  
  993.  
  994. MPATROL(3)               mpatrol library               MPATROL(3)
  995.  
  996.  
  997.               will not be logged.
  998.  
  999.        LLOOGGFFIILLEE=_s_t_r_i_n_g
  1000.               Specifies an alternative file in which to place all
  1001.               diagnostics  from  the mpatrol library.  A filename
  1002.               of _s_t_d_e_r_r will send all diagnostics to  the  ssttddeerrrr
  1003.               file  stream  and  a filename of _s_t_d_o_u_t will do the
  1004.               equivalent with the ssttddoouutt file stream.  Note  that
  1005.               if  a  problem occurs while opening the log file or
  1006.               if any diagnostics require to be  displayed  before
  1007.               the  log  file  has  had a chance to be opened then
  1008.               they will  be  sent  to  the  ssttddeerrrr  file  stream.
  1009.               Default value: LLOOGGFFIILLEE=_m_p_a_t_r_o_l_._l_o_g
  1010.  
  1011.        LLOOGGFFRREEEESS
  1012.               Specifies  that  all memory deallocations are to be
  1013.               logged and sent to the log  file.   Note  that  any
  1014.               memory deallocations made internally by the library
  1015.               will not be logged.
  1016.  
  1017.        LLOOGGMMEEMMOORRYY
  1018.               Specifies that all  memory  operations  are  to  be
  1019.               logged  and sent to the log file.  These operations
  1020.               will be made by calls to functions such  as  mmeemmsseett
  1021.               and  mmeemmccppyy.   Note that any memory operations made
  1022.               internally by the library will not be logged.
  1023.  
  1024.        LLOOGGRREEAALLLLOOCCSS
  1025.               Specifies that all memory reallocations are  to  be
  1026.               logged  and  sent  to  the log file.  Note that any
  1027.               memory reallocations made internally by the library
  1028.               will not be logged.
  1029.  
  1030.        MMEEDDIIUUMMBBOOUUNNDD=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  1031.               Specifies  the  limit  in  bytes up to which memory
  1032.               allocations should be classified as medium  alloca-
  1033.               tions  for  profiling purposes.  This limit must be
  1034.               greater than the small  bound  but  less  than  the
  1035.               large bound.  Default value: MMEEDDIIUUMMBBOOUUNNDD=_2_5_6.
  1036.  
  1037.        NNOOFFRREEEE Specifies  that the mpatrol library should keep all
  1038.               reallocated and  freed  memory  allocations.   Such
  1039.               freed  memory  allocations  will then be flagged as
  1040.               freed and can be used by  the  library  to  provide
  1041.               better  diagnostics.   However, as no system memory
  1042.               will ever be reused by the  mpatrol  library,  this
  1043.               option  can quickly lead to a shortage of available
  1044.               system memory for a process.  Note that this option
  1045.               will always force a memory reallocation to return a
  1046.               pointer to newly-allocated memory, but  the  eexxppaanndd
  1047.               function will never be affected by this option.
  1048.  
  1049.        NNOOPPRROOTTEECCTT
  1050.               Specifies  that the mpatrol library's internal data
  1051.  
  1052.  
  1053.  
  1054. Release 1.2                16 May 2000                         16
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. MPATROL(3)               mpatrol library               MPATROL(3)
  1061.  
  1062.  
  1063.               structures should not be made read-only after every
  1064.               memory  allocation  reallocation  or  deallocation.
  1065.               This may significantly speed up execution but  this
  1066.               will  be  at the expense of less safety if the pro-
  1067.               gram accidentally overwrites some of the  library's
  1068.               internal  data  structures.   Note that this option
  1069.               has no effect on systems that do not support memory
  1070.               protection.
  1071.  
  1072.        OOFFLLOOWWBBYYTTEE=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  1073.               Specifies  an 8-bit byte pattern with which to fill
  1074.               the overflow buffers  of  all  memory  allocations.
  1075.               This  is used internally to ensure that nothing has
  1076.               been written beyond the beginning or the end  of  a
  1077.               block  of allocated memory.  Note that this setting
  1078.               will only have an effect if the OOFFLLOOWWSSIIZZEE option is
  1079.               in use.  Default value: OOFFLLOOWWBBYYTTEE=_0_x_A_A.
  1080.  
  1081.        OOFFLLOOWWSSIIZZEE=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  1082.               Specifies the size in bytes to use for all overflow
  1083.               buffers, which must be a power of two (and will  be
  1084.               rounded  up  to  the  nearest power of two if it is
  1085.               not).  This is used internally to ensure that noth-
  1086.               ing  has  been  written beyond the beginning or the
  1087.               end of a block of allocated memory.  Note that this
  1088.               setting  specifies  the  size  for  only one of the
  1089.               overflow buffers given to each  memory  allocation;
  1090.               the  other  overflow  buffer will have an identical
  1091.               size.  No overflow buffers will  be  used  if  this
  1092.               setting is zero.  Default value: OOFFLLOOWWSSIIZZEE=_0.
  1093.  
  1094.        OOFFLLOOWWWWAATTCCHH
  1095.               Specifies that watch point areas should be used for
  1096.               overflow buffers rather than filling with the over-
  1097.               flow byte.  This can significantly reduce the speed
  1098.               of program execution.  Note that this option has no
  1099.               effect  on  systems that do not support watch point
  1100.               areas.
  1101.  
  1102.        PPAAGGEEAALLLLOOCC=_L_O_W_E_R|_U_P_P_E_R
  1103.               Specifies that each  individual  memory  allocation
  1104.               should  occupy  at least one page of virtual memory
  1105.               and should be placed at the lowest or highest point
  1106.               within  these  pages.   This  allows the library to
  1107.               place an overflow buffer of one page on either side
  1108.               of  every memory allocation and write-protect these
  1109.               pages as well as all free and freed  memory.   Note
  1110.               that  this  option has no effect on systems that do
  1111.               not support memory protection, and is  disabled  by
  1112.               default  on  other  systems as it can slow down the
  1113.               speed of program execution.
  1114.  
  1115.        PPRREESSEERRVVEE
  1116.               Specifies that  any  reallocated  or  freed  memory
  1117.  
  1118.  
  1119.  
  1120. Release 1.2                16 May 2000                         17
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. MPATROL(3)               mpatrol library               MPATROL(3)
  1127.  
  1128.  
  1129.               allocations  should  preserve  their  original con-
  1130.               tents.  This option must be used  with  the  NNOOFFRREEEE
  1131.               option and has no effect otherwise.
  1132.  
  1133.        PPRROOFF   Specifies that all memory allocations and dealloca-
  1134.               tions are to be profiled and sent to the  profiling
  1135.               output file.  Memory reallocations are treated as a
  1136.               memory deallocation immediately followed by a  mem-
  1137.               ory allocation.
  1138.  
  1139.        PPRROOFFFFIILLEE=_s_t_r_i_n_g
  1140.               Specifies an alternative file in which to place all
  1141.               memory allocation profiling  information  from  the
  1142.               mpatrol  library.   A  filename of _s_t_d_e_r_r will send
  1143.               this information to the ssttddeerrrr file  stream  and  a
  1144.               filename  of _s_t_d_o_u_t will do the equivalent with the
  1145.               ssttddoouutt file stream.  Note that if a problem  occurs
  1146.               while  opening  the  profiling output file then the
  1147.               profiling information will be sent  to  the  ssttddeerrrr
  1148.               file  stream.  Default value: PPRROOFFFFIILLEE=_m_p_a_t_r_o_l_._o_u_t.
  1149.  
  1150.        PPRROOGGFFIILLEE=_s_t_r_i_n_g
  1151.               Specifies an alternative  filename  with  which  to
  1152.               locate the executable file containing the program's
  1153.               symbols.  On most systems, the library  will  auto-
  1154.               matically  be  able to determine this filename, but
  1155.               on a few systems this option may have  to  be  used
  1156.               before any or all symbols can be read.
  1157.  
  1158.        RREEAALLLLOOCCSSTTOOPP=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  1159.               Specifies a reallocation index at which to stop the
  1160.               program when a memory allocation is  being  reallo-
  1161.               cated.   If  the  AALLLLOOCCSSTTOOPP option is non-zero then
  1162.               the program will  be  halted  when  the  allocation
  1163.               matching  that  allocation index is reallocated the
  1164.               specified number of times.  Otherwise  the  program
  1165.               will  be  halted  the  first time any allocation is
  1166.               reallocated the specified number  of  times.   Note
  1167.               that  this  setting will be ignored if its value is
  1168.               zero.  Default value: RREEAALLLLOOCCSSTTOOPP=_0.
  1169.  
  1170.        SSAAFFEESSIIGGNNAALLSS
  1171.               Instructs the library to save and  replace  certain
  1172.               signal  handlers  during  the  execution of library
  1173.               code and to restore them afterwards.  This was  the
  1174.               default  behaviour  in  version  1.0 of the mpatrol
  1175.               library and was changed since some memory-intensive
  1176.               programs  became  very  hard to interrupt using the
  1177.               keyboard, thus giving the impression that the  pro-
  1178.               gram or system had hung.
  1179.  
  1180.        SSHHOOWWAALLLL
  1181.               Equivalent  to  the SSHHOOWWFFRREEEEDD, SSHHOOWWUUNNFFRREEEEDD, SSHHOOWWMMAAPP
  1182.               and SSHHOOWWSSYYMMBBOOLLSS options specified together.
  1183.  
  1184.  
  1185.  
  1186. Release 1.2                16 May 2000                         18
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. MPATROL(3)               mpatrol library               MPATROL(3)
  1193.  
  1194.  
  1195.        SSHHOOWWFFRREEEEDD
  1196.               Specifies that a summary of all of the freed memory
  1197.               allocations  should be displayed at the end of pro-
  1198.               gram execution.  This option must be used  in  con-
  1199.               junction  with the NNOOFFRREEEE option and this step will
  1200.               not be performed if an abnormal termination  occurs
  1201.               or if there were no freed allocations.
  1202.  
  1203.        SSHHOOWWMMAAPP
  1204.               Specifies  that  a  memory  map  of the entire heap
  1205.               should be displayed at the end  of  program  execu-
  1206.               tion.  This step will not be performed if an abnor-
  1207.               mal termination occurs or if the heap is empty.
  1208.  
  1209.        SSHHOOWWSSYYMMBBOOLLSS
  1210.               Specifies that a summary of  all  of  the  function
  1211.               symbols  read  from  the  program's executable file
  1212.               should be displayed at the end  of  program  execu-
  1213.               tion.  This step will not be performed if an abnor-
  1214.               mal termination occurs or if no  symbols  could  be
  1215.               read from the executable file.
  1216.  
  1217.        SSHHOOWWUUNNFFRREEEEDD
  1218.               Specifies that a summary of all of the unfreed mem-
  1219.               ory allocations should be displayed at the  end  of
  1220.               program execution.  This step will not be performed
  1221.               if an abnormal termination occurs or if  there  are
  1222.               no unfreed allocations.
  1223.  
  1224.        SSMMAALLLLBBOOUUNNDD=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  1225.               Specifies  the  limit  in  bytes up to which memory
  1226.               allocations should be classified as  small  alloca-
  1227.               tions  for  profiling purposes.  This limit must be
  1228.               greater than zero but  less  than  the  medium  and
  1229.               large bounds.  Default value: SSMMAALLLLBBOOUUNNDD=_3_2.
  1230.  
  1231.        UUNNFFRREEEEDDAABBOORRTT=_u_n_s_i_g_n_e_d _i_n_t_e_g_e_r
  1232.               Specifies the minimum number of unfreed allocations
  1233.               at which to abort the program just  before  program
  1234.               termination.  A summary of all the allocations will
  1235.               be displayed on  the  standard  error  file  stream
  1236.               before  aborting.  This option may be handy for use
  1237.               in batch tests as it can force  tests  to  fail  if
  1238.               they  do  not  free  up  a minimum number of memory
  1239.               allocations.   Note  that  this  setting  will   be
  1240.               ignored  if  its  value  is  zero.   Default value:
  1241.               UUNNFFRREEEEDDAABBOORRTT=_0.
  1242.  
  1243.        UUSSEEDDEEBBUUGG
  1244.               Specifies that any  debugging  information  in  the
  1245.               executable file should be used to obtain additional
  1246.               source-level information.  This  option  will  only
  1247.               have  an  effect  if the executable file contains a
  1248.               compiler-generated line number table  and  will  be
  1249.  
  1250.  
  1251.  
  1252. Release 1.2                16 May 2000                         19
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. MPATROL(3)               mpatrol library               MPATROL(3)
  1259.  
  1260.  
  1261.               ignored if the mpatrol library was built to support
  1262.               an object file access library that cannot read line
  1263.               tables from object files.
  1264.  
  1265.        UUSSEEMMMMAAPP
  1266.               Specifies  that the library should use mmmmaapp instead
  1267.               of ssbbrrkk to allocate system  memory  on  UNIX  plat-
  1268.               forms.   This  option  should  be used if there are
  1269.               problems when using the mpatrol library in combina-
  1270.               tion with another malloc library which uses ssbbrrkk to
  1271.               allocate its memory.  It is ignored on systems that
  1272.               do not support the mmmmaapp system call.
  1273.  
  1274. SSEEEE AALLSSOO
  1275.        mmppaattrrooll(1),  mmpprrooff(1),  mmlleeaakk(1),  mmmmaapp(2),  ssbbrrkk(2), mmaall--
  1276.        lloocc(3), mmeemmoorryy(3), ssttrriinngg(3), aasssseerrtt(3), eellff(3e),  bbffdd(3).
  1277.  
  1278.        The mpatrol manual, reference card and FAQ.
  1279.  
  1280.        http://www.cbmamiga.demon.co.uk/mpatrol/
  1281.  
  1282. AAUUTTHHOORR
  1283.        Graeme S. Roy <graeme@epc.co.uk>
  1284.  
  1285. CCOOPPYYRRIIGGHHTT
  1286.        Copyright (C) 1997-2000 Graeme S. Roy <graeme@epc.co.uk>
  1287.  
  1288.        This  library  is  free  software; you can redistribute it
  1289.        and/or modify it under the terms of the GNU  Library  Gen-
  1290.        eral  Public  License  as  published  by the Free Software
  1291.        Foundation; either version 2 of the License, or  (at  your
  1292.        option) any later version.
  1293.  
  1294.        This  library  is  distributed in the hope that it will be
  1295.        useful, but WITHOUT ANY WARRANTY; without even the implied
  1296.        warranty  of  MERCHANTABILITY  or FITNESS FOR A PARTICULAR
  1297.        PURPOSE.  See the GNU Library General Public  License  for
  1298.        more details.
  1299.  
  1300.        You should have received a copy of the GNU Library General
  1301.        Public License along with this library; if not,  write  to
  1302.        the Free Software Foundation, Inc., 59 Temple Place, Suite
  1303.        330, Boston, MA 02111-1307, USA.
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318. Release 1.2                16 May 2000                         20
  1319.  
  1320.  
  1321.